package com.pdg.mcplugin.ih;

import java.io.File;

import org.bukkit.ChatColor;

public class Constants {
	public final static String loggerName = "Minecraft";
	
	public final static String commandIH = "ih";
	public final static String subcommandHelp = "help";
	public final static String subcommandQuestion = "?";
	public final static String subcommandTradingpost = "tradingpost";
	public final static String subcommandBuy = "buy";
	public final static String subcommandSell = "sell";
	public final static String subcommandPrice = "price";
	public final static String subcommandPrices = "prices";
	public final static String subcommandAdmin = "admin";
	public final static String subcommandInfo = "info";
	
	public final static Integer argSubcommand = 0;
	public final static Integer argBuySellCount = 1;
	public final static Integer argBuySellItemNameStart = 2;
	public final static Integer argPriceItemNameStart = 1;
	public final static Integer argPricesPageNumber = 1;
	
	public final static Integer argCountZero = 0;
	public final static Integer argCountSingle = 1;
	public final static Integer argCountDouble = 2;
	public final static Integer argCountTriple = 3;

	public final static String pluginPrefix = "[IH] ";
	public final static String pluginSuccess = ChatColor.GREEN + pluginPrefix;
	public final static String pluginFail = ChatColor.RED + pluginPrefix;
	public final static String pluginInfo = ChatColor.AQUA + pluginPrefix;
	
	public final static String errorCouldNotCreateDataFolder = pluginPrefix + "Could not create data folder!";
	public final static String errorCouldNotLoadSQLite = pluginPrefix + "Could not load SQLite!";
	public final static String errorCouldNotConnectToDatabase = pluginPrefix + "Could not connecto to database!";
//	public final static String errorCannotBuyNonPositiveQuantity = pluginFail + "Cannot buy a non-positive quantity!";
	public static final String errorBadCommand = pluginFail + "Command not recognized. Type /"+commandIH+" for general help!";
	
	public final static String messagePluginEnabled = pluginPrefix +  "Plugin enabled.";
	public final static String messagePluginDisabled = pluginPrefix +  "Plugin disabled.";
	public final static String messageIConomyHooked = pluginPrefix + "iConomy hooked.";
	public final static String messageIConomyUnhooked = pluginPrefix + "iConomy unhooked.";
	public final static String messageCreatedDataFolder = pluginPrefix + "Data folder created.";
	
	public final static String pluginIConomy = "iConomy";
	
	public final static String classNameSQLite = "org.sqlite.JDBC";
	public final static String classNameIConomy = "com.iConomy.iConomy";
	
	public final static String connectionString = "jdbc:sqlite:%s"+ File.separator + "ih.db";
	
	public final static String tablePrices = "ih_prices";
	public final static String fieldPricesIdentifier = "identifier";
	public final static String fieldPricesItem = "item";
	public final static String fieldPricesDurability = "durability";
	public final static String fieldPricesData = "data";
	public final static String fieldPricesAmount = "amount";
	public final static String fieldPricesBase = "base_price";
	public final static String fieldPricesBaseSupply = "base_supply";
	public final static String fieldPricesBaseDemand = "base_demand";
	public final static String fieldPricesSupplyFactor = "supply_factor";
	public final static String fieldPricesDemandFactor = "demand_factor";
	public final static String fieldPricesMarkup = "mark_up";
	public final static String fieldPricesPurchases = "purchases";
	public final static String fieldPricesSales = "sales";
	public final static String fieldPricesMaySell = "may_sell";
	public final static String fieldPricesMayPurchase = "may_purchase";
	
	public final static String tablePriceEnchantments = "ih_price_enchantments";
	//fieldPricesIdentifier
	public final static String fieldEnchantment = "enchantment";
	public final static String fieldLevel = "level";
	
	public final static String dbCheckForPricesTable = "SELECT `name` FROM `sqlite_master` WHERE `type`='table' AND `name`='"+tablePrices+"';";
	public final static String dbCreatePricesTable = "CREATE TABLE IF NOT EXISTS `"+tablePrices+"` (`"+fieldPricesIdentifier+"` AS TEXT UNIQUE, `"+fieldPricesAmount+"` AS INTEGER, `"+fieldPricesDurability+"` AS INTEGER, `"+fieldPricesData+"` AS INTEGER, `"+fieldPricesItem+"` AS INTEGER, `"+fieldPricesBase+"` AS REAL, `"+fieldPricesBaseSupply+"` AS REAL, `"+fieldPricesBaseDemand+"` AS REAL, `"+fieldPricesSupplyFactor+"` AS REAL, `"+fieldPricesDemandFactor+"` AS REAL, `"+fieldPricesMarkup+"` AS REAL, `"+fieldPricesPurchases+"` AS INTEGER, `"+fieldPricesSales+"` AS INTEGER, `"+fieldPricesMaySell+"` AS INTEGER, `"+fieldPricesMayPurchase+"` AS INTEGER);";
	
	public final static String dbCheckForPriceEnchantmentsTable = "SELECT `name` FROM `sqlite_master` WHERE `type`='table' AND `name`='"+tablePriceEnchantments+"';";
	public final static String dbCreatePriceEnchantmentsTable = "CREATE TABLE IF NOT EXISTS `"+tablePriceEnchantments+"` (`"+fieldPricesIdentifier+"` AS TEXT, `"+fieldEnchantment+"` AS INTEGER, `"+fieldLevel+"` AS INTEGER);";
	
	public final static Integer itemCountZero = 0;
	
	public final static String[] helpGeneral = {
		"/"+commandIH+" ("+subcommandHelp+"|"+subcommandQuestion+") - general help",
		"/"+commandIH+" "+subcommandTradingpost+" - trading post help",
		"/"+commandIH+" "+subcommandBuy+" - buying help",
		"/"+commandIH+" "+subcommandSell+" - selling help",
		"/"+commandIH+" "+subcommandInfo+" - info help",
		"/"+commandIH+" "+subcommandPrice+" - price help",
		"/"+commandIH+" "+subcommandPrices+" - prices help",
		"/"+commandIH+" "+subcommandAdmin+" - admin help",
	};	
	
	public final static String[] helpTradingpost = {
		"Place a sign on a double step with \"[TRADING POST]\" as one of the lines."
	};
	
	public final static String[] helpBuy = {
		"/"+commandIH+" "+subcommandBuy+" [number] [commodity]"
	};
	
	public final static String[] helpSell = {
		"/"+commandIH+" "+subcommandSell+" [number] [commodity]"
	};
	
	public final static String[] helpInfo = {
		"/"+commandIH+" "+subcommandInfo+" [commodity]"
	};
	
	public final static String[] helpPrice = {
		"/"+commandIH+" "+subcommandPrice+" [commodity]"
	};
	
	public final static String[] helpPrices = {
		"/"+commandIH+" "+subcommandPrices+" (page)"
	};

	public final static String[] helpAdmin = {
		"/"+commandIH+" "+subcommandAdmin+" create - create help",
		"/"+commandIH+" "+subcommandAdmin+" delete - delete help",
		"/"+commandIH+" "+subcommandAdmin+" retrieve - retrieve help",
		"/"+commandIH+" "+subcommandAdmin+" update - update help"
	};

}
